package com.zyfu.demo.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * <b>请输入名称</b>
 * <pre>
 * 描述<br/>
 * 作用：；<br/>
 * 限制：；<br/>
 * </pre>
 *
 * @author 张永福
 * @since  2024/2/26 21:28
 */
public enum DistrictLevel {
    country("国", "country", 0),
    province("省", "province", 1),
    city("市", "city", 2),
    district("县", "district", 3),
    street("街道", "street", 4),
    ;
    private final String name;

    private final String levelCode;
    private final Integer levelNum;

    private static final Map<String, DistrictLevel> CODE_2_NAME = new HashMap<>();
    static {
        DistrictLevel[] values = DistrictLevel.values();
        for (DistrictLevel level : values) {
            CODE_2_NAME.put(level.getLevelCode(), level);
        }
    }

    DistrictLevel(String name, String levelCode, Integer levelNum) {
        this.name = name;
        this.levelCode = levelCode;
        this.levelNum = levelNum;
    }

    public String getName() {
        return name;
    }

    public String getLevelCode() {
        return levelCode;
    }

    public Integer getLevelNum() {
        return levelNum;
    }

    public static DistrictLevel parse(String code) {
        return CODE_2_NAME.get(code);
    }
}
